import type { KnowledgePage, KnowledgeParams } from '@/types/consult'
import type { DoctorPage, PageParams, FollowType } from '@/types/consult'
import { request } from '@/utils/request'

export const getKnowledgePage = (params: KnowledgeParams) =>
  request<KnowledgePage>('/patient/home/knowledge', 'GET', params)

export const getDoctorPage = (params: PageParams) => request<DoctorPage>('/home/page/doc', 'GET', params)

export const followDoc = (id: string, type: FollowType) =>
  request('/like', 'POST', {
    id,
    type
  })

import type { TopDep } from '@/types/consult'

export const getAllDep = () => request<TopDep[]>('/dep/all')

import type { ConsultOrderPreData, ConsultOrderPreParams } from '@/types/consult'

export const getConsultOrderPre = (params: ConsultOrderPreParams) =>
  request<ConsultOrderPreData>('/patient/consult/order/pre', 'GET', params)

import type { PartialConsult } from '@/types/consult'
// 根据前面收集到的信息生成订单 ID
export const createConsultOrder = (data: PartialConsult) =>
  request<{ id: string }>('/patient/consult/order', 'POST', data)

// 获取支付地址 0 是微信 1 支付宝
// 获取支付地址 ===> 让页面跳转进入这个地址
export const getConsultOrderPayUrl = (params: { paymentMethod: 0 | 1; orderId: string; payCallback: string }) =>
  request<{ payUrl: string }>('/patient/consult/pay', 'POST', params)

export const getConsultOrderDetail = (orderId: string) => request('/patient/consult/order/detail', 'get', { orderId })
